package org.jash.ting13.entity

import org.jash.converters.Xpath
import kotlin.random.Random

data class PlayResult (
    @Xpath("//meta[@name='_c']/@content")
     val sc:String,
    @Xpath("//meta[@name='_b']/@content")
    val nid:String,
    @Xpath("//meta[@name='_p']/@content")
    val cid:String,
    @Xpath("//meta[@name='_d']/@content")
    val sort:String,
) {
    val sp:String
        get() {
            val code = "PXhw7U1B0a9kQDKZsTjIASmOeNzxYG4CHo1JyRfg2b8FLpEvr3FtVnlqMidu6c"
            val builder = StringBuilder()
            sc.forEach {
                builder.append(code[Random.nextInt(62)])
                builder.append(if (it in code) code[(code.indexOf(it) + 3) % 62] else it)
                builder.append(code[Random.nextInt(62)])
            }
            return builder.toString()
        }
}